package game.entity.action;

import edu.monash.fit2099.engine.Action;
import edu.monash.fit2099.engine.Actor;
import edu.monash.fit2099.engine.GameMap;
import edu.monash.fit2099.engine.Item;
import game.CoinPoint;

public class BuyAction extends Action {
    private Item goods;

    public BuyAction(Item goods) {
        this.goods = goods;
    }

    @Override
    public String execute(Actor actor, GameMap map) {
        int soldPoints = goods.getsoldPoints();
        if(CoinPoint.getPoints() >= soldPoints){
            actor.addItemToInventory(goods);
            CoinPoint.subPoints(soldPoints);
            return "successfully buy "+goods;
        }else{
            return "you don't have enough coinpoints, can't buy "+goods;
        }
    }

    @Override
    public String menuDescription(Actor actor) {
        return actor +" buy "+goods;
    }
}
